package Mario;

import com.sun.deploy.cache.BaseLocalApplicationProperties;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class StaticValue {
    //背景
    public static BufferedImage bg1 = null;
    public static BufferedImage bg2 = null;
    //向左跳跃
    public static BufferedImage leftjump = null;
    //向右跳跃
    public static BufferedImage rightjump = null;
    //向左站立
    public static BufferedImage leftstand = null;
    //向右站立
    public static BufferedImage rightstand = null;
    //城堡
    public static BufferedImage tower = null;
    //旗杆
    public static BufferedImage flagpole = null;
    //障碍物
    public static List<BufferedImage> barrier = new ArrayList<>();
    //向左跑
    public static List<BufferedImage> leftrun = new ArrayList<>();
    //向右跑
    public static List<BufferedImage> rightrun = new ArrayList<>();
    //蘑菇敌人
    public static List<BufferedImage> mushroom = new ArrayList<>();
    //食人花敌人
    public static List<BufferedImage> Chomper = new ArrayList<>();
    //路径前缀
    public static String path = System.getProperty("user.dir") + "/src/Mario/imgs/";

    //初始化方法
    public static void init() {

        try {
            //加载背景图片
            bg1 = ImageIO.read(new File(path + "bg.png"));
            bg2 = ImageIO.read(new File(path + "bg2.png"));
            //加载向左站立
            leftstand = ImageIO.read(new File(path + "s_mario_stand_L.png"));
            //加载向右站立
            rightstand = ImageIO.read(new File(path + "s_mario_stand_R.png"));
            //加载城堡
            tower = ImageIO.read(new File(path + "tower.png"));
            //加载旗杆
            flagpole = ImageIO.read(new File(path + "gan.png"));
            //加载向左跳跃
            leftjump = ImageIO.read(new File(path + "s_mario_jump1_L.png"));
            //加载向右跳跃
            rightjump = ImageIO.read(new File(path + "s_mario_jump1_R.png"));

        } catch (IOException e) {
            e.printStackTrace();
        }
        //加载向左跑
        for (int i = 1; i <= 2; i++) {
            try {
                leftrun.add(ImageIO.read(new File(path + "s_mario_run" + i + "_L.png")));
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
        //加载向右跑
        for (int i = 1; i <= 2; i++) {
            try {
                rightrun.add(ImageIO.read(new File(path + "s_mario_run" + i + "_R.png")));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //记载障碍物
        try {
            barrier.add(ImageIO.read(new File(path + "brick.png")));
            barrier.add(ImageIO.read(new File(path + "soil_up.png")));
            barrier.add(ImageIO.read(new File(path + "soil_base.png")));
        } catch (IOException e) {
            e.printStackTrace();
        }

        //加载水管
        for (int i = 1; i <= 4; i++) {

            try {
                barrier.add(ImageIO.read(new File(path + "pipe" + i +".png")));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //记载不可破坏的旗杆和水管
        try {
            barrier.add(ImageIO.read(new File(path + "brick2.png")));
            barrier.add(ImageIO.read(new File(path + "flag.png")));
        } catch (IOException e) {
            e.printStackTrace();
        }
        //记载蘑菇敌人
        for (int i = 1; i <= 3; i++) {
            try {
                mushroom.add(ImageIO.read(new File(path + "fungus" + i + ".png")));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //记载食人花敌人
        for (int i = 1; i <= 2; i++) {
            try {
                Chomper.add(ImageIO.read(new File(path + "flower1." + i + ".png")));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
